﻿using System;

namespace _70_将泛型参数限制为枚举类型_泛型
{
    class Program
    {
        static void Main(string[] args)
        {
            (string Name, int Val) res = CallTest(Oper.Open);
            Console.WriteLine($"枚举常量名{res.Name},常量值：{res.Val}");
        }

        static (string,int) CallTest<T>(T p) where T :Enum{
            //获取常量名称
            string name = Enum.GetName(p.GetType(), p);
            //获取常量
            int value = Convert.ToInt32(p);
            return (name, value);

        }


        public enum Oper
        {
            Open=5,
            Close=12,
            Reset=6
        }
    }
}
